const {User} = require('../../model/user');

module.exports = async (req, res) => {
    req.app.locals.current = 'user';

    // 将用户信息从数据库中查询出来
    const id = req.query.id;

    if(id){
        // 修改操作
        let user = await User.findOne({_id: id});
        res.render('admin/user-edit', {
            user,
            link: '/admin/user-modify?id=' + id,
            button: "修改"
        })
    }else{
        // 增加操作
        let user = {}
        res.render("admin/user-edit", {
            user,
            link: "/admin/user-add",
            button: "添加"
        })
    }
}